<template>
  <div class="app-container">
    <el-card>
      <el-tabs v-model="activityName" class="demo-tabs">
        <el-tab-pane label="待选样品" name="first">
          <isSelected ref="isSelectedRef" v-if="activityName == 'first'" @add="handleAdd" :iden="1"/>
        </el-tab-pane>
        <el-tab-pane label="已选样品" name="two">
          <isSelected ref="isSelectedRef" v-if="activityName == 'two'" @edit="handleEdit" :iden="2"/>
        </el-tab-pane>
      </el-tabs>
    </el-card>
    <newBuiltTab ref="newBuiltTabRef" @close="close"></newBuiltTab>
  </div>
</template>

<script setup name="LabMethod">
import newBuiltTab from "./newBuilt.vue";
import isSelected from "./isSelected.vue";

const activityName = ref("first");
const newBuiltTabRef = ref(null);
const isSelectedRef = ref(null);
function handleAdd(row) {
  newBuiltTabRef.value.open = true;
  newBuiltTabRef.value.title = "选择样品";
  newBuiltTabRef.value.parentId = row.lMId;
  newBuiltTabRef.value.methodId = row.methodId;
  nextTick(() => {
    newBuiltTabRef.value.getView();
  });
}

function handleEdit(row) {
  newBuiltTabRef.value.open = true;
  newBuiltTabRef.value.title = "数据填报";
  newBuiltTabRef.value.parentId = row.parentId;
  newBuiltTabRef.value.lMId = row.lMId;
  newBuiltTabRef.value.methodId = row.methodId;
  if (row.status != 0) {
    newBuiltTabRef.value.myId = row.lMId;
    newBuiltTabRef.value.tabsView();
  } else {
    nextTick(() => {
      newBuiltTabRef.value.getView();
    });
  }
}

function close() {
  isSelectedRef.value.getList();
}
</script>
